<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Daftar_surat extends CI_Controller {
	
	function __construct(){		
		parent::__construct();	
		$this->load->library('encryption');
		$this->load->library('zend');
		//$this->output->enable_profiler(true);
		
		$this->load->model('mdl_daftar_surat');
		
	}

	function barcode (){
		$desa = $this->config->item('kode_desa');
		$this->zend->load('Zend/Barcode');
        $data['barcode'] =  Zend_Barcode::render(
								'code128',
								'image',
								array(
								    'text' => $desa,
								    'font' => 2
							));
	}

	function index(){
		$data['page_title']='Buat Surat';
		$data['page_icon']='icon-envelope';
		$data['page_content']='surat';

		$this->load->view('layout/master',$data);
	}

	function list_surat(){
		$data['page_title']='List Surat';
		$data['page_icon']='icon-envelope';
		$data['page_content']='list_surat';

		$this->load->view('layout/master',$data);
	}

	function grid(){
		$data = $this->mdl_daftar_surat->getdata();
		echo $this->mdl_daftar_surat->togrid($data['row_data'], $data['row_count']);
	}
	
	# untuk form tambah
	function surat_keterangan(){
		# nomor surat
		$tahun = date("Y");
		$get_nomer_terakhir = $this->mdl_daftar_surat->getNoTerakhir();
		$nomer_terakhir = $get_nomer_terakhir + 1;
		$sk_surat = $this->config->item('j_surat');
		$desa = $this->config->item('kode_desa');
		$data['nomer_surat'] = $sk_surat['SK']."/".$nomer_terakhir."/".$desa."/".$tahun;
		# end nomor surattt

		$data['w_negara'] ='';
		$data['alamat'] ='';
		$data['keterangan'] ='';
		$data['tanda_tangan'] ='';
		
		$this->load->view('surat_keterangan',$data);
	}
	
	function surat_keterangan_pindah(){
		# nomor surat
		$tahun = date("Y");
		$get_nomer_terakhir = $this->mdl_daftar_surat->getNoTerakhirSKP();
		$nomer_terakhir = $get_nomer_terakhir + 1;
		$sk_surat = $this->config->item('j_surat');
		$desa = $this->config->item('kode_desa');
		$data['nomer_surat'] = $sk_surat['SKP']."/".$nomer_terakhir."/".$desa."/".$tahun;
		# end nomor surattt

		// untuk grid
		$data['anggota_keluarga'] = json_encode(array('total'=>0, 'rows'=>array()));
		
		$data['w_negara'] ='';
		$data['alamat'] ='';
		$data['pindah_ke'] ='';
		$data['alasan'] ='';
		$data['tgl_pindah'] ='';
		$data['tanda_tangan'] ='';
		
		$this->load->view('surat_keterangan_pindah',$data);
	}

	function surat_keterangan_adat(){
		# nomor surat
		$tahun = date("Y");
		$get_nomer_terakhir = $this->mdl_daftar_surat->getNoTerakhirSKA();
		$nomer_terakhir = $get_nomer_terakhir + 1;
		$sk_surat = $this->config->item('j_surat');
		$desa = $this->config->item('kode_desa');
		$data['nomer_surat'] = $sk_surat['SKA']."/".$nomer_terakhir."/".$desa."/".$tahun;
		# end nomor surattt

		// untuk grid
		//$data['anggota_keluarga'] = json_encode(array('total'=>0, 'rows'=>array()));
		
		$data['w_negara'] ='';
		$data['alamat'] ='';
		$data['pindah_ke'] ='';
		$data['alasan'] ='';
		$data['keterangan'] ='';
		$data['tgl_pindah'] ='';
		$data['tanda_tangan'] ='';
		
		$this->load->view('surat_keterangan_adat',$data);
	}

	function surat_keterangan_domisili(){
		# nomor surat
		$tahun = date("Y");
		$get_nomer_terakhir = $this->mdl_daftar_surat->getNoTerakhirSKD();
		$nomer_terakhir = $get_nomer_terakhir + 1;
		$sk_surat = $this->config->item('j_surat');
		$desa = $this->config->item('kode_desa');
		$data['nomer_surat'] = $sk_surat['SKD']."/".$nomer_terakhir."/".$desa."/".$tahun;
		# end nomor surattt

		$data['w_negara'] ='';
		$data['alamat'] ='';
		$data['keterangan'] ='';
		$data['tanda_tangan'] ='';
		
		$this->load->view('surat_keterangan_domisili',$data);
	}

	function surat_keterangan_usaha(){
		# nomor surat
		$tahun = date("Y");
		$get_nomer_terakhir = $this->mdl_daftar_surat->getNoTerakhirSKU();
		$nomer_terakhir = $get_nomer_terakhir + 1;
		$sk_surat = $this->config->item('j_surat');
		$desa = $this->config->item('kode_desa');
		$data['nomer_surat'] = $sk_surat['SKU']."/".$nomer_terakhir."/".$desa."/".$tahun;
		# end nomor surattt

		$data['w_negara'] ='';
		$data['alamat'] ='';
		$data['keterangan'] ='';
		$data['tanda_tangan'] ='';
		
		$this->load->view('surat_keterangan_usaha',$data);
	}

	function surat_keterangan_lainnya(){
		# nomor surat
		$tahun = date("Y");
		$get_nomer_terakhir = $this->mdl_daftar_surat->getNoTerakhir();
		$nomer_terakhir = $get_nomer_terakhir + 1;
		$sk_surat = $this->config->item('j_surat');
		$desa = $this->config->item('kode_desa');
		$data['nomer_surat'] = $sk_surat['SK']."/".$nomer_terakhir."/".$desa."/".$tahun;
		# end nomor surattt
		
		$data['alamat'] ='';
		$data['keterangan'] ='';
		$data['tanda_tangan'] ='';
		
		$this->load->view('surat_keterangan_lainnya',$data);
	}
	
	function surat_keterangan_lahir(){
		# nomor surat
		$tahun = date("Y");
		$get_nomer_terakhir = $this->mdl_daftar_surat->getNoTerakhirSL();
		$nomer_terakhir = $get_nomer_terakhir + 1;
		$sk_surat = $this->config->item('j_surat');
		$desa = $this->config->item('kode_desa');
		$data['nomer_surat'] = $sk_surat['SL']."/".$nomer_terakhir."/".$desa."/".$tahun;
		# end nomor surattt
		
		$data['nama'] ='';
		$data['hari'] ='';
		$data['tgl_lahir'] ='';
		$data['t_lahir'] ='';
		$data['ayah'] ='';
		$data['ibu'] ='';
		$data['alamat']='';
		$data['tanda_tangan'] ='';
		
		$this->load->view('surat_keterangan_lahir',$data);
	}

	function surat_keterangan_kematian(){
		# nomor surat
		$tahun = date("Y");
		$get_nomer_terakhir = $this->mdl_daftar_surat->getNoTerakhirSM();
		$nomer_terakhir = $get_nomer_terakhir + 1;
		$sk_surat = $this->config->item('j_surat');
		$desa = $this->config->item('kode_desa');
		$data['nomer_surat'] = $sk_surat['SM']."/".$nomer_terakhir."/".$desa."/".$tahun;
		# end nomor surattt
		
		$data['nama'] ='';
		$data['hari'] ='';
		$data['tgl_kematian'] ='';
		$data['t_kematian'] ='';
		$data['umur'] ='';
		$data['penyebab'] = '';
		$data['alamat']='';
		$data['tanda_tangan'] ='';
		
		$this->load->view('surat_keterangan_kematian',$data);
	}

	function penduduk_by_ktp($no_ktp){
		$data = $this->mdl_daftar_surat->getDataByktp($no_ktp)->row();
		
		echo json_encode($data);
	}

	# untuk surat keterangan
	public function save_sk(){
		$data = '';
		// get post
		foreach ($_POST as $key => $value) {
			$data[$key] = $value;
		}
		
		//echo json_encode($data);
		// save
		if($this->mdl_daftar_surat->save_sk($data)){
			echo json_encode(array('success'=>true, 'no_surat'=>$this->encryption->encode($data['nomer_surat'])));
		}else{
			echo json_encode(array('success'=>false, 'msg'=>'error insert to database'));
		}

	}

	public function pdf_sk($no_surat){
		$this->load->library('HTML2PDF');
		$html2pdf = new HTML2PDF('P', 'A4', 'fr');
		$html2pdf->setDefaultFont('Arial');
		
		// ambil data dari tabel
		$res = $this->mdl_daftar_surat->get_surat_by_nomer($this->encryption->decode($no_surat));
		$parag = $this->mdl_daftar_surat->getKonten();
		// init data
		$data['nama_kab'] = $this->config->item('kop_surat1');
		$data['nama_kec'] =  $this->config->item('kop_surat2');
		$data['nama_desa'] =  $this->config->item('kop_surat3');
		//$data['surat'] = 'Subang';
		$data['alamat_des'] =  $this->config->item('kop_surat4');
		$data['telp'] =  $this->config->item('kop_surat5');

		$data['no_surat'] = $res->row()->no_surat;
		$data['tanggal'] = $res->row()->tanggal;
		$data['nama_surat'] = $res->row()->nama_surat;
		$data['alamat'] = $res->row()->alamat;
		$data['paragraf_1'] = $parag->row()->paragraf_1;
		$data['paragraf_2'] = $parag->row()->paragraf_2;
		$data['paragraf_3'] = $parag->row()->paragraf_3;
		$data['paragraf_4'] = $parag->row()->paragraf_4;

		#barcode
		$this->zend->load('Zend/Barcode');
       //  $data['barcode'] =  Zend_Barcode::render(
							// 	'code128',
							// 	'image',
							// 	array(
							// 	    'text' => $no_surat,
							// 	    'font' => 2
							// ));

		
		//$data['list_anggota_keluarga'] = json_decode($r->row()->anggota, true);
		$data['isi'] = json_decode($res->row()->isi_surat, true);
		//$data['list_keluarga'] = $isi['list_anggota_keluarga'];
		$data['ttd'] = json_decode($res->row()->tanda_tangan, true);
		
		$konten = $this->load->view('pdf_surat_sk', $data, true);

		$html2pdf->writeHTML($konten, false);
		
		$html2pdf->Output('pdf_surat_sk.pdf');
	}


	# Save Surat Keterangan Pindah
	public function save_skp(){
		$data = '';
		// get post
		foreach ($_POST as $key => $value) {
			$data[$key] = $value;
		}

		$data['list_anggota_keluarga'] = json_decode($data['anggota_keluarga']);
		unset($data['anggota_keluarga']);

		//echo json_encode($data);
		// save
		if($this->mdl_daftar_surat->save_skp($data)){
			echo json_encode(array('success'=>true, 'no_surat'=>$this->encryption->encode($data['nomer_surat'])));
		}else{
			echo json_encode(array('success'=>false, 'msg'=>'error insert to database'));
		}

	}

	public function pdf_skp($no_surat){
		$this->load->library('HTML2PDF');
		$html2pdf = new HTML2PDF('P', 'A4', 'fr');
		$html2pdf->setDefaultFont('Arial');
		
		// ambil data dari tabel
		$res = $this->mdl_daftar_surat->get_surat_by_nomer($this->encryption->decode($no_surat));
		$parag = $this->mdl_daftar_surat->getKontenSKP();
		// init data
		$data['nama_kab'] = $this->config->item('kop_surat1');
		$data['nama_kec'] =  $this->config->item('kop_surat2');
		$data['nama_desa'] =  $this->config->item('kop_surat3');
		//$data['surat'] = 'Subang';
		$data['alamat_des'] =  $this->config->item('kop_surat4');
		$data['telp'] =  $this->config->item('kop_surat5');

		$data['no_surat'] = $res->row()->no_surat;
		$data['tanggal'] = $res->row()->tanggal;
		$data['nama_surat'] = $res->row()->nama_surat;
		$data['alasan'] = $res->row()->alasan;
		$data['pindah_ke'] = $res->row()->pindah_ke;
		$data['alamat'] = $res->row()->alamat;
		$data['paragraf_1'] = $parag->row()->paragraf_1;
		$data['paragraf_2'] = $parag->row()->paragraf_2;
		$data['paragraf_3'] = $parag->row()->paragraf_3;
		$data['paragraf_4'] = $parag->row()->paragraf_4;

		//$data['list_anggota_keluarga'] = json_decode($r->row()->anggota, true);
		$data['isi'] = json_decode($res->row()->isi_surat, true);
		//$data['list_keluarga'] = $isi['list_anggota_keluarga'];
		$data['ttd'] = json_decode($res->row()->tanda_tangan, true);
		
		$konten = $this->load->view('pdf_surat_skp', $data, true);
		
		$html2pdf->writeHTML($konten, false);
		
		$html2pdf->Output('surat_skp.pdf');
	}

	# untuk surat keterangan adat
	public function save_ska(){
		$data = '';
		// get post
		foreach ($_POST as $key => $value) {
			$data[$key] = $value;
		}
		//$data['list_anggota_keluarga'] = json_decode($data['anggota_keluarga']);
		//unset($data['anggota_keluarga']);

		//echo json_encode($data);
		// save
		if($this->mdl_daftar_surat->save_ska($data)){
			echo json_encode(array('success'=>true, 'no_surat'=>$this->encryption->encode($data['nomer_surat'])));
		}else{
			echo json_encode(array('success'=>false, 'msg'=>'error insert to database'));
		}

	}

	public function pdf_ska($no_surat){
		$this->load->library('HTML2PDF');
		$html2pdf = new HTML2PDF('P', 'A4', 'fr');
		$html2pdf->setDefaultFont('Arial');
		
		// ambil data dari tabel
		$res = $this->mdl_daftar_surat->get_surat_by_nomer($this->encryption->decode($no_surat));
		$parag = $this->mdl_daftar_surat->getKontenSKA();
		// init data
		$data['nama_kab'] = $this->config->item('kop_surat1');
		$data['nama_kec'] =  $this->config->item('kop_surat2');
		$data['nama_desa'] =  $this->config->item('kop_surat3');
		//$data['surat'] = 'Subang';
		$data['alamat_des'] =  $this->config->item('kop_surat4');
		$data['telp'] =  $this->config->item('kop_surat5');

		$data['no_surat'] = $res->row()->no_surat;
		$data['tanggal'] = $res->row()->tanggal;
		$data['nama_surat'] = $res->row()->nama_surat;
		$data['alamat'] = $res->row()->alamat;
		$data['paragraf_1'] = $parag->row()->paragraf_1;
		$data['paragraf_2'] = $parag->row()->paragraf_2;
		$data['paragraf_3'] = $parag->row()->paragraf_3;
		$data['paragraf_4'] = $parag->row()->paragraf_4;

		//$data['list_anggota_keluarga'] = json_decode($r->row()->anggota, true);
		$data['isi'] = json_decode($res->row()->isi_surat, true);
		//$data['list_keluarga'] = $isi['list_anggota_keluarga'];
		$data['ttd'] = json_decode($res->row()->tanda_tangan, true);
		
		$konten = $this->load->view('pdf_surat_ska', $data, true);
		
		$html2pdf->writeHTML($konten, false);
		
		$html2pdf->Output('pdf_surat_ska.pdf');
	}

	# untuk surat keterangan Domisili
	public function save_skd(){
		$data = '';
		// get post
		foreach ($_POST as $key => $value) {
			$data[$key] = $value;
		}
		
		//echo json_encode($data);
		// save
		if($this->mdl_daftar_surat->save_skd($data)){
			echo json_encode(array('success'=>true, 'no_surat'=>$this->encryption->encode($data['nomer_surat'])));
		}else{
			echo json_encode(array('success'=>false, 'msg'=>'error insert to database'));
		}

	}

	public function pdf_skd($no_surat){
		$this->load->library('HTML2PDF');
		$html2pdf = new HTML2PDF('P', 'A4', 'fr');
		$html2pdf->setDefaultFont('Arial');
		
		// ambil data dari tabel
		$res = $this->mdl_daftar_surat->get_surat_by_nomer($this->encryption->decode($no_surat));
		$parag = $this->mdl_daftar_surat->getKontenSKD();
		// init data
		$data['nama_kab'] = $this->config->item('kop_surat1');
		$data['nama_kec'] =  $this->config->item('kop_surat2');
		$data['nama_desa'] =  $this->config->item('kop_surat3');
		//$data['surat'] = 'Subang';
		$data['alamat_des'] =  $this->config->item('kop_surat4');
		$data['telp'] =  $this->config->item('kop_surat5');

		$data['no_surat'] = $res->row()->no_surat;
		$data['tanggal'] = $res->row()->tanggal;
		$data['nama_surat'] = $res->row()->nama_surat;
		$data['alamat'] = $res->row()->alamat;
		$data['paragraf_1'] = $parag->row()->paragraf_1;
		$data['paragraf_2'] = $parag->row()->paragraf_2;
		$data['paragraf_3'] = $parag->row()->paragraf_3;
		$data['paragraf_4'] = $parag->row()->paragraf_4;

		//$data['list_anggota_keluarga'] = json_decode($r->row()->anggota, true);
		$data['isi'] = json_decode($res->row()->isi_surat, true);
		//$data['list_keluarga'] = $isi['list_anggota_keluarga'];
		$data['ttd'] = json_decode($res->row()->tanda_tangan, true);
		
		$konten = $this->load->view('pdf_surat_skd', $data, true);
		
		$html2pdf->writeHTML($konten, false);
		
		$html2pdf->Output('pdf_surat_skd.pdf');
	}

	# untuk surat keterangan Usaha
	public function save_sku(){
		$data = '';
		// get post
		foreach ($_POST as $key => $value) {
			$data[$key] = $value;
		}
		
		//echo json_encode($data);
		// save
		if($this->mdl_daftar_surat->save_sku($data)){
			echo json_encode(array('success'=>true, 'no_surat'=>$this->encryption->encode($data['nomer_surat'])));
		}else{
			echo json_encode(array('success'=>false, 'msg'=>'error insert to database'));
		}

	}

	public function pdf_sku($no_surat){
		$this->load->library('HTML2PDF');
		$html2pdf = new HTML2PDF('P', 'A4', 'fr');
		$html2pdf->setDefaultFont('Arial');
		
		// ambil data dari tabel
		$res = $this->mdl_daftar_surat->get_surat_by_nomer($this->encryption->decode($no_surat));
		$parag = $this->mdl_daftar_surat->getKontenSKU();
		// init data
		$data['nama_kab'] = $this->config->item('kop_surat1');
		$data['nama_kec'] =  $this->config->item('kop_surat2');
		$data['nama_desa'] =  $this->config->item('kop_surat3');
		//$data['surat'] = 'Subang';
		$data['alamat_des'] =  $this->config->item('kop_surat4');
		$data['telp'] =  $this->config->item('kop_surat5');

		$data['no_surat'] = $res->row()->no_surat;
		$data['tanggal'] = $res->row()->tanggal;
		$data['nama_surat'] = $res->row()->nama_surat;
		$data['alamat'] = $res->row()->alamat;
		$data['paragraf_1'] = $parag->row()->paragraf_1;
		$data['paragraf_2'] = $parag->row()->paragraf_2;
		$data['paragraf_3'] = $parag->row()->paragraf_3;
		$data['paragraf_4'] = $parag->row()->paragraf_4;

		//$data['list_anggota_keluarga'] = json_decode($r->row()->anggota, true);
		$data['isi'] = json_decode($res->row()->isi_surat, true);
		//$data['list_keluarga'] = $isi['list_anggota_keluarga'];
		$data['ttd'] = json_decode($res->row()->tanda_tangan, true);
		
		$konten = $this->load->view('pdf_surat_sku', $data, true);
		
		$html2pdf->writeHTML($konten, false);
		
		$html2pdf->Output('pdf_surat_sku.pdf');
	}

	# untuk surat keterangan Lainnya
	public function save_skl(){
		$data = '';
		// get post
		foreach ($_POST as $key => $value) {
			$data[$key] = $value;
		}
		
		//echo json_encode($data);
		// save
		if($this->mdl_daftar_surat->save_skd($data)){
			echo json_encode(array('success'=>true, 'no_surat'=>$this->encryption->encode($data['nomer_surat'])));
		}else{
			echo json_encode(array('success'=>false, 'msg'=>'error insert to database'));
		}

	}

	public function pdf_skl($no_surat){
		$this->load->library('HTML2PDF');
		$html2pdf = new HTML2PDF('P', 'A4', 'fr');
		$html2pdf->setDefaultFont('Arial');
		
		// ambil data dari tabel
		$res = $this->mdl_daftar_surat->get_surat_by_nomer($this->encryption->decode($no_surat));

		// init data
		$data['nama_desa'] = 'Desa ...';
		$data['no_surat'] = $res->row()->no_surat;
		$data['isi'] = json_decode($res->row()->isi_surat, true);
		
		$konten = $this->load->view('pdf_surat_skl', $data, true);
		
		$html2pdf->writeHTML($konten, false);
		
		$html2pdf->Output('pdf_surat_skl.pdf');
	}
	
	# Save Surat Keterangan Lahir
	public function save_sl(){
		$data = '';
		// get post
		foreach ($_POST as $key => $value) {
			$data[$key] = $value;
		}
		// $data['list_anggota_keluarga'] = json_decode($data['anggota_keluarga']);
		// unset($data['anggota_keluarga']);

		//echo json_encode($data);
		// save
		if($this->mdl_daftar_surat->save_sl($data)){
			echo json_encode(array('success'=>true, 'no_surat'=>$this->encryption->encode($data['nomer_surat'])));
		}else{
			echo json_encode(array('success'=>false, 'msg'=>'error insert to database'));
		}

	}

	# Save Surat Keterangan Lahir
	public function pdf_sl($no_surat){
		$this->load->library('HTML2PDF');
		$html2pdf = new HTML2PDF('P', 'A4', 'fr');
		$html2pdf->setDefaultFont('Arial');
		
		// ambil data dari tabel
		$res = $this->mdl_daftar_surat->get_surat_by_nomer($this->encryption->decode($no_surat));
		$parag = $this->mdl_daftar_surat->getKontenSL();
		// init data
		$data['nama_kab'] = $this->config->item('kop_surat1');
		$data['nama_kec'] =  $this->config->item('kop_surat2');
		$data['nama_desa'] =  $this->config->item('kop_surat3');
		//$data['surat'] = 'Subang';
		$data['alamat_des'] =  $this->config->item('kop_surat4');
		$data['telp'] =  $this->config->item('kop_surat5');

		$data['no_surat'] = $res->row()->no_surat;
		$data['tanggal'] = $res->row()->tanggal;
		$data['nama_surat'] = $res->row()->nama_surat;
		$data['alamat'] = $res->row()->alamat;
		$data['paragraf_1'] = $parag->row()->paragraf_1;
		$data['paragraf_2'] = $parag->row()->paragraf_2;
		$data['paragraf_3'] = $parag->row()->paragraf_3;
		$data['paragraf_4'] = $parag->row()->paragraf_4;

		//$data['list_anggota_keluarga'] = json_decode($r->row()->anggota, true);
		$data['isi'] = json_decode($res->row()->isi_surat, true);
		//$data['list_keluarga'] = $isi['list_anggota_keluarga'];
		$data['ttd'] = json_decode($res->row()->tanda_tangan, true);
		
		$konten = $this->load->view('pdf_surat_lahir', $data, true);
		
		$html2pdf->writeHTML($konten, false);
		
		$html2pdf->Output('surat_skp.pdf');
	}

	# Save Surat Keterangan Kematian
	public function save_sm(){
		$data = '';
		// get post
		foreach ($_POST as $key => $value) {
			$data[$key] = $value;
		}
		// $data['list_anggota_keluarga'] = json_decode($data['anggota_keluarga']);
		// unset($data['anggota_keluarga']);

		//echo json_encode($data);
		// save
		if($this->mdl_daftar_surat->save_sm($data)){
			echo json_encode(array('success'=>true, 'no_surat'=>$this->encryption->encode($data['nomer_surat'])));
		}else{
			echo json_encode(array('success'=>false, 'msg'=>'error insert to database'));
		}

	}

	# Save Surat Keterangan Kematian
	public function pdf_sm($no_surat){
		$this->load->library('HTML2PDF');
		$html2pdf = new HTML2PDF('P', 'A4', 'fr');
		$html2pdf->setDefaultFont('Arial');
		
		// ambil data dari tabel
		$res = $this->mdl_daftar_surat->get_surat_by_nomer($this->encryption->decode($no_surat));
		$parag = $this->mdl_daftar_surat->getKontenSM();
		// init data
		$data['nama_kab'] = $this->config->item('kop_surat1');
		$data['nama_kec'] =  $this->config->item('kop_surat2');
		$data['nama_desa'] =  $this->config->item('kop_surat3');
		//$data['surat'] = 'Subang';
		$data['alamat_des'] =  $this->config->item('kop_surat4');
		$data['telp'] =  $this->config->item('kop_surat5');
		
		$data['no_surat'] = $res->row()->no_surat;
		$data['tanggal'] = $res->row()->tanggal;
		$data['nama_surat'] = $res->row()->nama_surat;
		$data['alamat'] = $res->row()->alamat;
		$data['paragraf_1'] = $parag->row()->paragraf_1;
		$data['paragraf_2'] = $parag->row()->paragraf_2;
		$data['paragraf_3'] = $parag->row()->paragraf_3;
		$data['paragraf_4'] = $parag->row()->paragraf_4;

		//$data['list_anggota_keluarga'] = json_decode($r->row()->anggota, true);
		$data['isi'] = json_decode($res->row()->isi_surat, true);
		//$data['list_keluarga'] = $isi['list_anggota_keluarga'];
		$data['ttd'] = json_decode($res->row()->tanda_tangan, true);
		
		$konten = $this->load->view('pdf_surat_kematian', $data, true);
		
		$html2pdf->writeHTML($konten, false);
		
		$html2pdf->Output('surat_skp.pdf');
	}	

}